<?php
App::uses('AppModel', 'Model');
/**
 * Payment Model
 *
 * @property Subscription $Subscription
 * @property PaymentType $PaymentType
 */
class Payment extends AppModel {
/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'id';

/**
 * belongsTo associations
 *
 * @var array
 */
	public $hasMany = array(
		'Subscription' => array(
			'className' => 'Subscription',
			'foreignKey' => 'payment_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
		
	);
        
        public function checkIPNID($txnId) {
            $payment = $this->find('first', array('conditions' => array('Payment.txn_id' => $txnId) ));
            
            if ( !empty($payment) ) {
                return $payment;
            }
            return false;
            
        }
        /**
         * Create Payment for pick up method
         *  
         */
        public function savePayment($data) {
            $this->create();
            if ($this->save($data)) {
                return $this->id;
            }
            return false;
        }
}
